export const usersStore = defineStore('users', () => {
	const users = reactive({})

	const setUsers = (value) => {
		Object.assign(users, value)
	}

	const clearUsers = () => {
		Object.keys(users).forEach(key => delete users[key])
	}

	const deleteUsers = (key) => {
		delete users[key]
	}

	const removeUsers = (key) => {
		Object.keys(users).forEach(key => delete users[key])
		uni.removeStorageSync(key)
	}
	const isMe = (userid)=>{
		return users.id == userid
	}
	const isFuJing = ()=>{
		return users.roleType != 'masses'
	}
	return {
		users,
		isMe,
		isFuJing,
		setUsers,
		clearUsers,
		deleteUsers,
		removeUsers
	}
}, {
	persist: {
		storage: {
			getItem: (key) => uni.getStorageSync(key),
			setItem: (key, value) => uni.setStorageSync(key, value)
		}
	}
})
